/**
 * Writed by yura and mak
 */

package wz.legend.handlers.steps;

import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

import org.apache.commons.digester.Digester;

public class StepLoader {

    public static List<Step> loadSteps(InputStream stream) {
        List<Step> list = null;

        try {
            Digester digester = new Digester();
            digester.setValidating(false);
            digester.addObjectCreate("steps", LinkedList.class);
            digester.addObjectCreate("steps/step", "class", Object.class);
            digester.addSetNext("steps/step", "add");
            digester.addSetProperties("steps/step/param");
            list = (List<Step>) digester.parse(stream);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return list;
    }
}
